#include <iostream>
#include <climits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

int main() {
    int k;
    cin >> k;
    int arr[k];
    for (int i = 0; i < k; i++)
    {
        cin >> arr[i];
    }
    int left = 0;
    int right = 0;
    int prev = 0;
    int my_max = 0;
    while (right < k)
    {
        if (prev <= arr[right] + 8)
        {
            ;
        }
        else
        {
            left = right;
        }
        if (right - left + 1 > my_max)
        {
            my_max = right - left;
        }
        prev = arr[right];
        right++;
    }
    cout << my_max << endl;
    return 0;
}

class Solution {
public:
    int countPath(vector<vector<int> >& CityMap, int n, int m) {
        // write code here
        vector<vector<int>> city(n + 2, vector<int>(m + 2));
        pair<int, int> x1;
        pair<int, int> x2;
        city[0][1] = 1;
        for (int i = 1; i < n + 1; i++)
        {
            for (int j = 1; j < m + 1; j++)
            {
                if (CityMap[i - 1][j - 1] == -1)
                {
                    continue;
                }
                if (CityMap[i - 1][j - 1] == 2)
                {
                    x1 = { i - 1,j - 1 };
                }
                if (CityMap[i - 1][j - 1] == 1)
                {
                    x2 = { i - 1,j - 1 };
                }
                city[i][j] = city[i - 1][j] + city[i][j - 1];
            }
        }
        city[0][1] = 0;
        int p = city[x1.first + 1][x1.second + 1];
        city[x1.first + 1][x1.second + 1] = city[x1.first][x1.second + 1] + city[x1.first + 1][x1.second] + city[x1.first + 2][x1.second + 1] + city[x1.first + 1][x1.second + 2] - 2 * p;
        p = city[x2.first + 1][x2.second + 1];
        city[x2.first + 1][x2.second + 1] = city[x2.first][x2.second + 1] + city[x2.first + 1][x2.second] + city[x2.first + 2][x2.second + 1] + city[x2.first + 1][x2.second + 2] - 2 * p;
        return max(city[x1.first + 1][x1.second + 1], city[x2.first + 1][x2.second + 1]);
    }
};

int main() {
    int k;
    cin >> k;
    int arr[k];
    for (int i = 0; i < k; i++)
    {
        cin >> arr[i];
    }
    int left = 0;
    int right = 0;
    int prev = 0;
    int my_max = 0;
    while (right < k)
    {
        if (prev >= arr[right] - 8)
        {
            ;
        }
        else
        {
            left = right;
        }
        prev = arr[right];
        if (right - left + 1 > my_max)
        {
            my_max = right - left + 1;
        }
        right++;
    }
    cout << my_max << endl;
    return 0;
}

int main() {
    int n;
    cin >> n;
    int prev = 0;
    int next = 1;
    while (next < n)
    {
        int sum = prev + next;
        prev = next;
        next = sum;
    }
    cout << min(abs(prev - n), abs(next - n)) << endl;
    return 0;
}

class Solution {
public:
    int _n, _m;
    int x1, x2, y1, y2;
    int dist[15][15] = { 0 };
    int cnt[15][15] = { 0 };
    int dx[4] = { 0,0,-1,1 };
    int dy[4] = { -1,1,0,0 };

    int bfs(vector<vector<int> >& CityMap)
    {
        memset(dist, -1, sizeof(dist));
        queue<pair<int, int>> q;
        q.push({ x1,y1 });
        dist[x1][y1] = 0;
        cnt[x1][y1] = 1;
        while (q.size())
        {
            auto [a, b] = q.front();
            q.pop();
            for (int i = 0; i < 4; i++)
            {
                int x = a + dx[i];
                int y = b + dy[i];
                if (x >= 0 && x < _n && y >= 0 && y < _m && CityMap[x][y] != -1)
                {
                    if (dist[x][y] == -1)
                    {
                        dist[x][y] = dist[a][b] + 1;
                        cnt[x][y] = cnt[a][b];
                        q.push({ x,y });
                    }
                    else
                    {
                        if (dist[a][b] + 1 == dist[x][y])
                        {
                            cnt[x][y] += cnt[a][b];
                        }
                    }
                }
            }
        }
        return cnt[x2][y2];
    }

    int countPath(vector<vector<int> >& CityMap, int n, int m) {
        // write code here
        _n = n;
        _m = m;
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                if (CityMap[i][j] == 1)
                {
                    x1 = i;
                    y1 = j;
                }
                if (CityMap[i][j] == 2)
                {
                    x2 = i;
                    y2 = j;
                }
            }
        }
        return bfs(CityMap);
    }
};

int main() {
    int n;
    cin >> n;
    vector<vector<int>> vt(n + 1, vector<int>(n + 1));
    vt[0][1] = 1;
    for (int i = 1; i < n + 1; i++)
    {
        for (int j = 1; j <= i; j++)
        {
            if (j == i)
            {
                vt[i][j] = 1;
            }
            else
            {
                vt[i][j] = vt[i - 1][j] + vt[i - 1][j - 1];
            }
            printf("%5d", vt[i][j]);
        }
        cout << endl;
    }
    return 0;
}

class Solution {
public:
    int bx[4] = { 0,0,1,-1 };
    int by[4] = { 1,-1,0,0 };
    int abs[101][101] = { 0 };
    int n, m, p;

    bool dfs(vector<string>& board, string word, int k, int x1, int y1)
    {
        if (k == p - 1)
        {
            return true;
        }
        abs[x1][y1] = 1;
        if (board[x1][y1] == word[k])
        {
            for (int i = 0; i < 4; i++)
            {
                int x = x1 + bx[i];
                int y = y1 + by[i];
                if (x >= 0 && x < n && y >= 0 && y < m && board[x][y] == word[k + 1] && abs[x][y] == 0)
                {
                    if (dfs(board, word, k + 1, x, y))
                    {
                        return true;
                    }
                }
            }
        }
        abs[x1][y1] = 0;
        return false;
    }

    bool exist(vector<string>& board, string word) {
        // write code here
        n = board.size();
        m = board[0].size();
        p = word.size();
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                if (board[i][j] == word[0])
                {
                    if (dfs(board, word, 0, i, j))
                    {
                        return true;
                    }
                }
            }
        }
        return false;
    }
};